<%@ Page Title="Member_AssetHistory List" Language="C#" AutoEventWireup="true" CodeBehind="Member_AssetHistoryList.aspx.cs" Inherits="Youz.CreditRepay.Manage.Member_AssetHistoryList" %>

<script>
    //loadCSS("assets/plugins/gritter/css/jquery.gritter.css");

    var requireJS = [
        //"assets/plugins/gritter/js/jquery.gritter.min.js"
    ];

    loadJS(requireJS);
    $(function () {
        $('.form_date').datetimepicker({
            language: "zh_CN",
            format: "yyyy-mm-dd",
            autoclose: true,
            todayBtn: true,
            todayHighlight: true,
            pickerPosition: "bottom-left",
            startView: 2,
            minView: 2,
            forceParse: 0
        });
    });
</script>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading" data-original-title="">
                <h2><i class="fa fa-align-justify"></i><span style="font-size: 16px; padding-right: 15px;"><%: R(LanguageModule.Member_AssetHistory, "Member_AssetHistory", "Member_AssetHistory") %></span></h2>
                <div class="panel-actions"></div>
            </div>
            <div class="panel-body">
                <div class="alert alert-danger" style="display: none;">
                    <button type="button" class="close" data-dismiss="alert">×</button><strong><i class="fa fa-warning"></i></strong><span class="content"></span>
                </div>
                <form class="form-horizontal">
                    <div class="row">
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %></label>
                                <div class="col-md-9">
                                    <input type="email" id="MemberAccount" maxlength="45" name="MemberAccount" class="form-control" placeholder="<%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>">
                                </div>
                            </div>
                        </div>
                        <div class="col-md-3">
                            <div class="form-group">
                                <label class="col-md-3 control-label" for="RoleDesc"><%: R(LanguageModule.Member_AssetHistory, "ChangeType", "变动类型") %></label>
                                <div class="col-md-9">
                                    <select name="ChangeType" id="ChangeType" class="form-control">
                                        <option value="">全部</option>
                                        <%
                                            Type ChangeType = typeof(Youz.CreditRepay.Entity.AssetHistoryChangeType);
                                            foreach (Youz.CreditRepay.Entity.AssetHistoryChangeType item in Enum.GetValues(ChangeType))
                                            {
                                                            
                                        %>
                                        <option value="<%= (int)item %>"><%=Utility.GetEnumDescription(item)  %></option>
                                        <%
                                            }
                                        %>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-4">
                            <div class="form-group">
                                <label class="col-md-3 control-label"><%: R(LanguageModule.Member_Withdraw, "createTime", "创建时间") %></label>
                                <div class="col-md-9">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" data-date-format="yyyy/mm/dd" id="StartDate" class="form-control form_date" />
                                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                                        <input type="text" data-date-format="yyyy/mm/dd" id="EndDate" class="form-control form_date" />
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <button type="button" id="btnQuery" name="btnQuery" class="btn btn-default btn-ar btn-primary">
                                <i class="fa fa-search "></i>
                                <%: R(LanguageModule.M_Common, "Query") %>
                            </button>
                        </div>
                    </div>
                </form>
                <table id="table" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var dt;

    $(function () {

        dt = $('#table').DataTable({
            "ajax": {
                "url": 'Member/Handlers/Member_AssetHistoryHandler.ashx?type=list',
                "type": "POST",
                "dataSrc": "data",
                "data": function (d) {
                    d.MemberAccount = $('#MemberAccount').val();
                    d.ChangeType = $('#ChangeType').val();
                    d.StartDate = $('#StartDate').val();
                    d.EndDate = $('#EndDate').val();
                }
            },
            "columns": [
                    { "data": 'RowIndex', "title": "#" },
                    { "data": 'HistoryID', "title": "<%: R(LanguageModule.Member_AssetHistory, "HistoryID", "记录ID") %>", visible: false },
                    { "data": 'MemberAccount', "title": "<%: R(LanguageModule.M_Common, "MemberAccount", "会员帐号") %>" },
                    { "data": 'AssetType', "title": "<%: R(LanguageModule.Member_AssetHistory, "AssetType", "资产类型") %>", render: AssetType },
                    { "data": 'ChangeType', "title": "<%: R(LanguageModule.Member_AssetHistory, "ChangeType", "变动类型") %>", render: ChangeType },
                    { "data": 'ChangeAgoBalance', "title": "<%: R(LanguageModule.Member_AssetHistory, "ChangeAgoBalance", "变动前余额") %>", render: fmoney },
                    { "data": 'ChangeBalance', "title": "<%: R(LanguageModule.Member_AssetHistory, "ChangeBalance", "变动额") %>", render: fmoney1 },
                    { "data": 'ChangeAfterBalance', "title": "<%: R(LanguageModule.Member_AssetHistory, "ChangeAfterBalance", "变动后余额") %>", render: fmoney },
                    { "data": 'Memo', "title": "<%: R(LanguageModule.Member_AssetHistory, "Memo", "备注") %>" },
                    { "data": 'ObjectID', "title": "<%: R(LanguageModule.Member_AssetHistory, "ObjectID", "对象ID ") %>" },
                    { "data": 'CreateTime', "title": "<%: R(LanguageModule.Member_AssetHistory, "CreateTime", "变动时间") %>" },
                    { "data": 'Creator', "title": "<%: R(LanguageModule.Member_AssetHistory, "Creator", "创建人") %>" },
            ]
        });
        $('#btnQuery').click(function () {
            if (validateStartDateEndDate($('#StartDate').val(), $('#EndDate').val())) {
                dt.ajax.reload();
            }
        });
    });
    function fmoney1(value, row, data) {
        //item.ChangeAgoBalance < item.ChangeAfterBalance ? "+" : "-";
        if (data.ChangeAgoBalance < data.ChangeAfterBalance) {
            return "<span style='color:green'>+" + Math.abs(data.ChangeBalance) + "</span>";
        }
        return "<span style='color:red'>-" + Math.abs(data.ChangeBalance) + "</span>";

    }
</script>
